package org.hugh.http;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

@Component
public class HttpInvoker {

    @Autowired
    private RestTemplate restTemplate;

    public <T> T get(String url, Class<T> clazz) {
        return restTemplate.getForObject(url, clazz);
    }

    public <T, R> T post(String url, R request, Class<T> clazz) {
        return restTemplate.postForObject(url, request, clazz);
    }
}
